from LongUI.page.login_page import LoginPage
from selenium.webdriver.common.by import By

class MenuPage(LoginPage):
    # 断言系统菜单
    dy1_loc=By.XPATH,'//*[@id="sidebar"]/div[1]/h2'
    def dy1(self):
        return self.text(self.dy1_loc)

    # 点击菜单管理
    menu_loc=By.XPATH,'/html/body/div[1]/div[2]/div[2]/div[2]/div[2]/ul/li[1]/div/a'
    def menu(self):
        self.click(self.menu_loc)

    # 点击添加
    addmenu_loc=(By.XPATH,'//*[@id="addMenu"]/span')
    def addmenu(self):
        self.click(self.addmenu_loc)

    def window(self):
        self.handles()

    # 输入菜单名称
    menuname_loc=(By.XPATH,'//*[@id="form"]/div[1]/p[2]/input')
    def menuname(self):
        self.send_keys(self.menuname_loc,'二组')

    # 输入菜单编号
    menuid_loc=By.XPATH,'//*[@id="form"]/div[1]/p[3]/input'
    def menuid(self):
        self.send_keys(self.menuid_loc,'222222')

    # 输入请求url
    menuurl_loc =By.NAME,'url'
    def menuurl(self):
        self.send_keys(self.menuurl_loc, 'url123')

    # 输入navTabld
    menunav_loc =By.XPATH,'//*[@id="form"]/div[1]/p[5]/input'
    def menunav(self):
        self.send_keys(self.menunav_loc, '不知道')

    # 点击保存
    save_loc=By.XPATH,'//*[@id="form"]/div[1]/p[5]/input'
    def save(self):
        self.click(self.save_loc)

    def menupage(self):
        self.longguo_login()
        print(self.dy1())
        assert '系统菜单'==self.dy1()
        self.menu()
        self.addmenu()
        self.window()
        self.menuname()
        self.menuid()
        self.menuurl()
        self.menunav()
        self.save()
